package wwk.com.android_meilishuo.ui.home.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wwk.core.utils.RecyclerViewAdapterHelper;

import java.util.List;

import wwk.com.android_meilishuo.R;
import wwk.com.android_meilishuo.ui.home.bean.ChannelBean;
import wwk.com.android_meilishuo.ui.home.bean.HomeHeadBean;
import wwk.com.android_meilishuo.utils.BitmapCircleTransformation;

/**
 * Created by Administrator on 2017/1/4.
 */

public class ChannelAdapter extends RecyclerViewAdapterHelper<ChannelBean.ListBean> {
    public ChannelAdapter(Context context, List<ChannelBean.ListBean> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_channel_recyclerview, null);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof MyViewHolder) {
            MyViewHolder myViewHolder = (MyViewHolder) holder;
            ChannelBean.ListBean listBean = mList.get(position);
            Glide.with(mContext).load(listBean.getImage()).transform(new BitmapCircleTransformation(mContext))
                    .into(myViewHolder.imageView_channel);
            myViewHolder.textView_channel.setText(listBean.getTitle());
        }

    }

    class MyViewHolder extends RecyclerView.ViewHolder {

        private ImageView imageView_channel;
        private TextView textView_channel;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView_channel = (ImageView) itemView.findViewById(R.id.image_channel);
            textView_channel = (TextView) itemView.findViewById(R.id.text_channel);
        }
    }

}
